﻿using MediatR;
using PLC.Domain.Models;
using PLC.Domain.Service.IRepository;

namespace PLC.Domain.Events.Handlers;

public class SaveRepairAirtightDataHandler:INotificationHandler<SaveRepairAirtightModel>
{
    private readonly IRepairAirtightDataRepository _repairAirtightDataRepository;

    public SaveRepairAirtightDataHandler(IRepairAirtightDataRepository repairAirtightDataRepository)
    {
        _repairAirtightDataRepository = repairAirtightDataRepository?? throw new ArgumentNullException(nameof(repairAirtightDataRepository));
    }
    public async Task Handle(SaveRepairAirtightModel notification, CancellationToken cancellationToken)
    {
        if (notification.RepairAirtightDatas.Count==0)
        {
            return;
        }

        await _repairAirtightDataRepository.CreateAsync(notification.RepairAirtightDatas);
    }
}